home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
print
/
spool.zip
/
SPOOL.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-02-01
|
39KB
|
1,074 lines
page 64,132
;----------------------------------------------------------------------------
; spooler program
;
; modified by craig derouen 6-6-84
;
; Version 2.0 by craig derouen 3-20-85
; : change communications interrupt with buffer
; : control to ioctl for better,more compatable
; : operation. Change additional interrupt to user
; : modifiable in case of conflicts.
; Version 2.2 by Craig Derouen 4-4-85
; : Change status return code so more compat with
; : other programs. Add a pause feature. Add reprint
; : last page feature.
;
; Configuring spooler:
;
; Install the folowing line you CONFIG.SYS file on the boot
; disk:
; device=spool.dev [/option1] [/option2]
;
; Where option may be the following:
; Option 1: "/1" -"/64" Decimal digit(s) indicating
; (k)size of memory to reserve for print
; buffer.
;
; Option 2: "/L(1,2,3)" or "/C(1,2)". Specifies which
; port is buffered, and becomes STANDARD
; PRN output. Only one may be specified.
; Option "L(1,2,3)" indicates LPT1,LPT2 or
; LPT3 respectively. Option "/C(1,2)" indicates
; Com1 or Com2 port.
;
; Thus if the following line is installed:
;
; device = spool.dev /l2 /60
;
; It means spool the PRN output to LPT2, reserve a 60K buffer.
;
; Options are not case sensitive! Options may be installed in
; any order. Any other characters are ignored. Default setup
; is:
; LPT1 and 1K buffer
;
user_int equ 67h ; Required additional interrupt. Just change
; it here if conflicts with anything.
formfeed equ 0ch ; Form feed char. This is the char the code
; looks for to indicate new page
;----------------------------------------------------------------------------
cseg segment para public 'CODE'
assume cs:cseg,es:cseg,ds:cseg
;----------------------------------------------------------------------------
; device driver header
;----------------------------------------------------------------------------
next_dev dd -1 ;pointer to next device
attribute dw 0C000h ;character type device with ioctl
strategy dw dev_strategy ;pointer to device strategy
interrupt dw dev_int ;pointer to dev_int
dev_name db 'PRN ' ;device indentifier
;-----------------------------------------------------------------------------
; f u n c t i o n t a b l e
;
; this is the table of procedures which are called to service each type
; of device driver request from ms-dos.
;-----------------------------------------------------------------------------
funtab label byte
dw init ;initialization routine
dw exit ;media check (block only)
dw exit ;build bpb "" ""
dw ioctl_in ;ioctl input
dw exit ;input (read)
dw nd_input ;non_destructive input no wait (char only)
dw exit ;input status
dw exit ;input flush
dw output ;output (write)
dw output ;output (write) with verify
dw out_stat ;output status
dw out_flush ;output flush
dw ioctl_out ;ioctl output
;-----------------------------------------------------------------------------
; working variables for bufferring of output
;-----------------------------------------------------------------------------
port_type db 0 ;flag specifying lpt or com port - com=0, lpt=1
rh_seg dd 0 ;request header pointer - segment and offset
data_seg dw 0 ;data segment for printer data
ending_address dw 0 ; this is the value past back to dos from the initialization routine
pull_ptr dw 0 ;points to the current character to output from the buffer
insert_ptr dw 0 ;points place to insert next character into buffer
buf_size dw 0 ;size of the printer buffer in characters
port_number db 0 ;current port number of output port (0,1) if com, (0,1,2) if parallel
move_cnt dw 0 ;amount of data moved
buf_flg db 0 ;not zero if buffer full
buff_cnt dw 0 ;amount of data in the buffer
loop_cnt dw 0 ;number of times around the loop
priority dw 100 ;processing priority
pointer_set db 0 ;non-zero if irq0 vector modifyied
ppause db 0 ; flag for printer pause
;-----------------------------------------------------------------------------
; device strategy routine
;
; this procedure gets the request header from ms-dos and sets up rh_seg
; as the pointer used in the buffer driver for manipulation of the request
; header
; entry: ex:bx --> pointer to request header from ms-dos
;
; exit: rh_seg --> our internal pointer to request header
;-----------------------------------------------------------------------------
dev_strategy proc far
mov word ptr cs:[rh_seg],bx ;save the request header segment
mov word ptr cs:[rh_seg+2],es ;save the request header offset
ret
dev_strategy endp
;------------------------------------------------------------------------------
;
; device interrupt handler
;
; this procedure is called each time ms-dos calls the driver. its task
; is to branch control to the proper procedure to service the request.
;
; this procedure saves all registers, uses rh_seg (pointer to request
; header) to get the command number, then uses the command number as an offset
; into the command table (funtab) to jump to the appropriate procedure to service
; the request from ms-dos to the driver
;
; entry: rh_seg --> pointer to request header
;
; exit: cx --> number of bytes to transfer (read or write)
; ex:di --> pointer to data (transfer address)
; jump to proper procedure to service request, if valid, or
; jump to ioctl_in if invalid command
;-----------------------------------------------------------------------------
dev_int proc far
push si
mov si,offset funtab ;point to the start of the function table
push ax ;save all registers onto the stack
push bx
push cx
push dx
push di
push bp
push ds
push es
lds bx,cs:rh_seg ;get the request header segment
mov cx,[bx+12h] ;get the amount of data to transfer
mov al,[bx+02h] ;get the command byte
cbw ;make 16 bit value
add si,ax ;add into our table value
add si,ax ;do it again
cmp al,12 ;is it above the last entry in our table
ja exit ;do null action if so
les di,[bx]+14d ;get pointer to our data
push cs ;make our data segment register
pop ds ;the same as our code segment register
jmp word ptr[si] ;jump to correct action in the table
;-----------------------------------------------------------------------------
; non destructive input routine
;
; this procedure always returns done and busy to ms-dos to indicate that
; there is no character in the buffer to return.
;
; entry: rh_seg --> pointer to request header from ms-dos
;
; exit: rh_seg --> return request header with done and busy set in
; status word, no other changes are made to the request header
; ah --> 0011 (done and busy bits set)
;----------------------------------------------------------------------------
nd_input:
mov ah,03 ;indicate done and buzy to dos
jmp short exit1 ;set our status word
;----------------------------------------------------------------------------
; dummy return point
;
; this is the return procedure for exiting the driver and returning control
; to ms-dos. the status word can be updated to indicate done and number of
; characters processed. the registers which were previously saved are restored
; prior to exiting.
;
; entry: ax,cx --> ah and al can be previously set as the status word
; should be jmped to.
;
; exit: ds:bx --> pointer to update request header to return to ms-dos
; es,ds,bp,di,dx,cx,bx,ax,si restored in that order
;-----------------------------------------------------------------------------
exit: mov ah,01 ;indicate done for status word
mov cx,cs:move_cnt ;get the amount of data move
exit1: lds bx,cs:rh_seg ;load request header segment
mov [bx+03],ax ;save our exit status word
mov [bx+12h],cx ;save the amount of data read
pop es ;restore the entry registers from the
pop ds ;stack before exiting
pop bp
pop di
pop dx
pop cx
pop bx
pop ax
pop si
ret
dev_int endp
;-----------------------------------------------------------------------------